package exercise03;

public class MyRunnable implements Runnable{
    int num = 1;
    @Override
    public void run() {
        while (true){
            synchronized (MyRunnable.class){
               if (num > 100){
                   break;
               } else{
                   if (num%2==1){
                       System.out.println(Thread.currentThread().getName()+" 打印："+num);
                   }
                   num++;
                   try {
                       Thread.sleep(20);
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
            }
        }
    }
}
